package StringTest;

import java.util.Scanner;



public class test1 {
    public static void main(String[] args) {
        //1.键盘录入一个字符串
        Scanner sc=new Scanner(System.in);
        String str;
        while (true) {
            System.out.println("请输入一个字符串：");
            str = sc.next();
            //2.校验字符串是否满足规则
            boolean flag = checkStr(str);
            if (flag) {
                break;
            } else {
                System.out.println("当前字符串不符合规则，请重新输入");
            }
        }
            //3.查找字符表
            StringBuilder sb=new StringBuilder();

            for (int i = 0; i < str.length(); i++) {
                char c=str.charAt(i);
                int num=c-48;
                String s=getLuoMaNum(num);
                sb.append(s);
            }
            System.out.println(sb);

    }

    public static String getLuoMaNum(int num){
        String[] arr={"","Ⅰ","Ⅱ","Ⅲ","Ⅳ","Ⅴ","Ⅵ","Ⅶ","Ⅷ","Ⅸ"};
        return arr[num];
    }

    public static boolean checkStr(String s){
        if(s.length()>9){
            return false;
        }

        for (int i = 0; i < s.length(); i++) {
            char c=s.charAt(i);
            if(c<'0'||c >'9'){
                return false;
            }
        }
        return true;
    }
}
